package net.hn.hnms.biz.sewage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.hn.hnms.biz.sewage.entity.SewageIndexPo;
import net.hn.hnms.biz.sewage.entity.SewageVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;

public interface SewageIndexaMapper extends BaseMapper<SewageIndexPo> {
    /**
     * 工业污水处理量及复用量
     * @param startDay
     * @param endDay
     * @param orgCode
     * @return
     */
    @Select("SELECT COALESCE(SUM(CAST(sewage_treatment AS INTEGER)),0) as sewageDisposeValue,COALESCE(SUM(CAST(reuse AS INTEGER)),0) as sewageReuseValue\n" +
            "FROM sewage_index sindex\n" +
            "INNER JOIN domestic_sewage_shift dss ON sindex.id = dss.index_id  WHERE sindex.fill_in_time >= #{startDay} AND sindex.fill_in_time <= #{endDay} AND sindex.mine_code=#{orgCode}")
    SewageVo getIndustrialSewageBigDecimal(@Param("startDay") Date startDay, @Param("endDay") Date endDay, @Param("orgCode") String orgCode);

    /**
     * 生活污水处理量及复用量
     * @param startDay
     * @param endDay
     * @param orgCode
     * @return
     */
    @Select("SELECT COALESCE(SUM(CAST(sewage_treatment AS INTEGER)),0) as sewageDisposeValue,COALESCE(SUM(CAST(reuse AS INTEGER)),0) as sewageReuseValue\n" +
            "from sewage_index sindex\n" +
            "INNER JOIN industrial_wastewater_shift iws on sindex.id = iws.index_id WHERE sindex.fill_in_time >= #{startDay} AND sindex.fill_in_time <= #{endDay} AND sindex.mine_code=#{orgCode}")
    SewageVo getDomesticSewageBigDecimal(@Param("startDay") Date startDay, @Param("endDay") Date endDay, @Param("orgCode") String orgCode);
}
